// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   LoginProcessor.java

package com.boci.clientapp.authentication.processor;

import com.boci.clientapp.authentication.vo.LoginVO;
import com.boci.common.constant.RequestTypeConst;
import com.boci.common.processor.AbstractResponseProcessor;
import com.boci.common.vo.ResponseVO;
import java.util.ArrayList;
import org.w3c.dom.*;

public class LoginProcessor extends AbstractResponseProcessor
{

    public LoginProcessor(String pXML, String pReqType, String pErrMsgPrefix)
        throws Exception
    {
        super(pXML, pReqType, pErrMsgPrefix);
        acctNoList = new ArrayList();
    }

    public ResponseVO processXML()
        throws Exception
    {
        String strReqType = getReqType();
        String strRespType = getRespType();
        if(strReqType.equals(RequestTypeConst.BOCI_LOGOUT_URL))
            return null;
        String strCustID = getNodeValue("CUST_ID");
        String strLang = getNodeValue("LANG");
        String strAAStocks_Login = getNodeValue("AASTOCKS_LOGIN");
        NodeList acctNodes = resultDocument.getElementsByTagName("ACCOUNT");
        if(acctNodes == null || acctNodes.getLength() <= 0)
        {
            throw new Exception("Missing ACCOUNT Element!");
        } else
        {
            processAcctNodes(acctNodes);
            LoginVO loginVO = new LoginVO(strRespType, getReturnCode());
            loginVO.setAcctNoList(acctNoList);
            loginVO.setCustID(strCustID);
            loginVO.setLang(strLang);
            loginVO.setPriAcctNo(strPriAcctNo);
            loginVO.setAAStock_Login(strAAStocks_Login);
            return loginVO;
        }
    }

    private void processAcctNodes(NodeList pAcctNode)
    {
        Node acctNode = pAcctNode.item(0);
        Element acctElmt = (Element)acctNode;
        NodeList acctNoNodes = acctElmt.getElementsByTagName("ACCOUNT_NO");
        for(int j = 0; j < acctNoNodes.getLength(); j++)
        {
            String strAttrValue = getAttrValue(acctNoNodes.item(j), "PRIMARY");
            String strAcctNo = getNodeValue(acctNoNodes.item(j));
            if(strAttrValue.equals("TRUE"))
                strPriAcctNo = strAcctNo;
            acctNoList.add(strAcctNo);
        }

    }

    ArrayList acctNoList;
    String strPriAcctNo;
}
